import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Line
from pyecharts.globals import ThemeType
df=pd.read_excel('全国居民人均可支配收入季度数据.xlsx',index_col=0)
df=df.iloc[:,::-1]
line=Line(init_opts=opts.InitOpts(
    width='800px',height='400px',
    theme=ThemeType.SHINE,page_title='面积图'
))
line.add_xaxis(xaxis_data=['第一季度','第二季度','第三季度','第四季度'])
line.add_yaxis(series_name='2020年',y_axis=df.iloc[0,0:4],areastyle_opts=opts.AreaStyleOpts(opacity=0.5))
line.add_yaxis(series_name='2021年',y_axis=df.iloc[0,4:8],areastyle_opts=opts.AreaStyleOpts(opacity=0.5))
line.add_yaxis(series_name='2022年',y_axis=df.iloc[0,8:12],areastyle_opts=opts.AreaStyleOpts(opacity=0.5))

line.set_global_opts(
    title_opts=opts.TitleOpts(
        title='2020-2022年每年个季度全国具名人均可支配收入面积图',
        pos_left='center'),
    yaxis_opts=opts.AxisOpts(name='全国人民人均可支配收入（元）',
                             name_location='center',name_gap=55,min_=6000),
    legend_opts=opts.LegendOpts(pos_right='10%',pos_top='8%')
)
line.render('例7-2.html')